package java编程思想.第18章._3_添加属性和有用的接口;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test {
	static String path = "D:\\test1.txt";
	public static void main(String[] args) {
		try {
			DataOutputStream out = new DataOutputStream(new FileOutputStream(path));
			out.writeInt(123);
			out.writeUTF("你好");
			out.writeBoolean(true);
			out.flush();
			out.close();//装饰

			DataInputStream in = new DataInputStream(new FileInputStream(path));
			int a = in.readInt();
			System.out.println("first int is " + a);
			String b = in.readUTF();
			System.out.println("second string is " + b);
			boolean c = in.readBoolean();
			System.out.println("third boolean is " + c);
			in.close();

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
